package cn.tedu.account.service;

import cn.tedu.account.mapper.AccountMapper;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Transactional
    @Override
    public void decrease(Long userId, BigDecimal money) {

        accountMapper.decrease(userId, money);
        if (Math.random() < 0.80) {
            throw new RuntimeException("模拟扣减账户金额失败");
        }

    }

}
